(function(angular) {
	'use strict';
	angular.module("fs.waf").factory("roleService", roleService);
	roleService.$inject = [ '$q', 'loggerFactory', 'modalService', 'gridService','ajaxServiceFactory' ,'storageService'];
	function roleService($q, loggerFactory, modalService, gridService, ajaxServiceFactory, storageService) {
		var ajaxService = ajaxServiceFactory.buildAjaxService({
			getSite : {
				url : 'do/cda/dataList/sites',
				method : 'get'
			},
			getDataStatus : {
				url : 'do/cda/dataList/dataStatus',
				method : 'get'
			}
		});
		
		function getDataStatus() {
			var defer = $q.defer();
			ajaxService.getDataStatus().then(function(response) {
				defer.resolve(response);
			});
			return defer.promise;
		}
		function getSiteOptions() {
			var defer = $q.defer();
			ajaxService.getSite().then(function(response) {
				defer.resolve(response);
			});
			return defer.promise;
		}
		
		return {
			initOptionForSearch :initOptionForSearch,
			getDataStatus : getDataStatus,
			getSiteOptions : getSiteOptions
		};
		
		
		function initOptionForSearch(ctrl){
			var defer1 = $q.defer();
			var defer2 = $q.defer();
			ajaxService.getSite().then(function(response) {
				if (response && response.data)
					response.hasEmptyOption = true;
				defer1.resolve(response);
			}, angular.noop);
			ajaxService.getDataStatus().then(function(response) {
				defer2.resolve(response ? response.data : {});
			}, angular.noop);
			return $q.all({
				siteOptions : defer1.promise,
				dataStatusOptions : defer2.promise
			});
		};
		
	}
})(angular);